package rsj.api.product;

import com.rlyy.aibase.utils.base.Box;
import com.rlyy.aibase.utils.base.MapNode;
import com.rlyy.aibase.utils.base.TableNode;
import common.util.BoxUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import rsj.api.user.BaseLink;
import rsj.dao.ProductDao;

/**
 * @author yuanqinglong
 * @since 2020/10/19 13:57
 */
@RestController
public class GetProductByType extends BaseLink {

    private final ProductDao productDao = ProductDao.getInstance();

    @Override
    @RequestMapping(value = "rsj_data_prodlist")
    public Box executeLink(Box box) {
        MapNode data = box.getMapNode("data");
        String typeFid = data.getValueDef("prod_type_fid","RJQ");
        TableNode tableNode = productDao.listByType(typeFid);
        MapNode outData = new MapNode();
        outData.putNode("__prodList__", tableNode.toJson());
        return BoxUtil.successBoxToData(box, "成功", outData);
    }
}
